package com.das.mechanic_base.base;

import android.app.Activity;
import android.app.Dialog;

import com.das.mechanic_base.utils.X3ToastUtils;
import com.das.mechanic_base.widget.X3LoadingDialog;

public class BaseViewProxy {

    private Activity mContext;

    private Dialog loadingDialog;

    public BaseViewProxy(Activity context) {
        this.mContext = context;
    }

    public void showToast(String text) {
        X3ToastUtils.showMessage(text +"");
    }

    public void showLoading(final String text) {
        if (loadingDialog == null) {
            loadingDialog = X3LoadingDialog.createLoadingDialog(mContext,text);
        }
        loadingDialog.show();
    }

    public void setCancelNo() {
        if (loadingDialog != null) {
            loadingDialog.setCancelable(false);
            loadingDialog.setCanceledOnTouchOutside(false);
        }
    }

    public void hideLoading() {
        if (loadingDialog != null && loadingDialog.isShowing()) {
            loadingDialog.dismiss();
            loadingDialog = null;
        }
    }

    public void destroy() {
        if (loadingDialog != null) {
            loadingDialog.dismiss();
            loadingDialog = null;
        }
    }
}
